<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        display: inline-block;
        width: 100px;
        height: 100px;
        background-color: red;
        margin-right: 20px;
      }
      .xxx-enter-active {
        transition: all 0.5s;
      }
      .xxx-leave-active {
        transition: all 0.5s;
      }
      .xxx-enter {
        transform: translateY(200px);
        opacity: 0;
      }
      .xxx-leave-to {
        transform: translateY(200px);
        opacity: 0;
      }
      .box:nth-child(1) {
        transition-delay: 0.2s;
      }
      .box:nth-child(2) {
        transition-delay: 0.4s;
      }
      .box:nth-child(3) {
        transition-delay: 0.6s;
      }
      .box:nth-child(4) {
        transition-delay: 0.8s;
      }
      .box:nth-child(5) {
        transition-delay: 1s;
      }
    </style>
  </head>

  <body>
    <div id="app">
      <button @click="bol=!bol">切换</button>
      <br />
      <!-- v-if与v-for 在vue里面不能一起用
            解决方案：
              1. 将 v-if 可以换成 v-show
              2. 可以用 template 标签包裹，在该标签上写 v-for
                  在内容标签上写 v-if
      -->
      <transition-group name="xxx">
        <div
          class="box"
          v-if="bol"
          v-for="(item, index) in 5"
          :key="index"
        ></div>
      </transition-group>
    </div>
    <script src="./vue.js"></script>
    <script>
      new Vue({
        el: '#app',
        data: {
          bol: true
        }
      })
    </script>
  </body>
</html>
